package com.atguigu.springboot.controller;

import com.atguigu.springboot.entities.Attraction;
import com.atguigu.springboot.service.AttractionService;
import com.atguigu.springboot.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;
@Controller
@RequestMapping("/attraction")
public class attractionController {

    @Autowired
    AttractionService attractionService;

    //获取所有景点
    @ResponseBody
    @GetMapping("/all")
    public List<Attraction> all(){
     return   attractionService.getAllAttraction();
    }



    //根据aid获取景点
    @ResponseBody
    @GetMapping("/get")
    public Attraction get(int aid){
        return   attractionService.getAttraction(aid);
    }


    //根据uid获取所有已打卡景点
    @ResponseBody
    @GetMapping("/getRegister")
    public List<Attraction> getRegister(int uid, HttpSession session){
        uid=(int)session.getAttribute("uid");
        System.out.println("_++++++++++++++++"+uid);
        return attractionService.getRegisterAttraction(uid);
    }
    //根据uid获取所有未打卡景点
    @ResponseBody
    @GetMapping("/getNoRegister")
    public List<Attraction> getNoRegister(int uid,HttpSession session){
        uid=(int)session.getAttribute("uid");
        return attractionService.getNoRegisterAttraction(uid);
    }
}
